<head th:fragment="headerCss">
    <meta charset="utf-8">
    <title>湖南金职伟业母婴护理有限公司</title>
    <meta content="width=device-width, initial-scale=1.0" name="viewport">
    <meta name="keywords" content=""/>
    <meta name="description"
          content="湖南金职伟业母婴护理有限公司"/>
    <link rel="stylesheet" href="/js/layui/css/layui.css">
    <!-- Bootstrap CSS File -->
    <!--<link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">-->
    <link rel="stylesheet" href="/css/examination/common.css">
    <link href="/css/font-awesome.css?v=4.4.0"
          th:href="@{/css/font-awesome.css?v=4.4.0}" rel="stylesheet">
    <!-- Google Fonts -->
    <link rel="shortcut icon" href="favicon.ico">
    <link rel="stylesheet" href="/css/swiper-bundle.css">

    <style>
        .ti1{float: left;width: 20%;line-height: 42px;color: #333}
        .ti2{float: right !important;width: 75%;text-align: left !important;}
        #examinationList,.layui-input{border-color: #ccc;border-radius: 5px;color: #999 !important; font-size: 12px !important;}
        .windowstor{height: initial;}
        .tips{font-size: 25px;color: #E60214;display: none;width: 400px;margin: 30px auto 0;}

        .newtoptit{width: 100%;margin: 75px auto 37px; text-align: center;}
        .newtoptit img{width: 128px;height: 126px;display: block;margin: 0 auto;}
        .newaddtips{margin: 0;}
    </style>
</head>
<body class="signin">

<div class="main_content has_back">
    <div class="window_box windowstor">
        <div class="leftForm">

            <div class="toptit"><img src="/img/red_logo.png" /></div>

            <div class="tips" id="tips">请升级你的浏览器，该浏览器不支持此考试系统，建议使用谷歌浏览器！(谷歌浏览器可进行正常考试)</div>

            <div class="loginIn">

                <div class="item">
                    <label class="ti1">考试批次</label>
                    <select id="examinationList" name="examinationList" class="ti2 layui-input">
                        <option value="" checked>请选择考试批次</option>
                    </select>
                    <div style="clear: both"></div>
                </div>

                <div class="item">
                    <label class="ti1">姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名</label>
                    <input  type="text" id="username" placeholder="请输入姓名" autocomplete="new-password" class="ti2 layui-input">
                    <div style="clear: both"></div>
                </div>
                <div class="item">
                    <label class="ti1">准考证号</label>
                    <input type="text" id="ticketNumber" placeholder="请输入准考证号" autocomplete="new-password"
                           class="ti2 layui-input">
                    <div style="clear: both"></div>
                </div>

                <div class="item">
                    <label class="ti1">考试编号</label>
                    <input type="text" id="idNumber" placeholder="请输入考生编号" autocomplete="new-password" class="ti2 layui-input">
                    <div style="clear: both"></div>
                </div>
                <!--<div class="item" style="text-align: right">-->
                <!--<label ><a href="/examination/abnormal">考试异常恢复</a></label>-->
                <!--</div>-->
                <div class="item">
                    <input type="hidden" th:value="${time}" id="times" />
                    <input type="hidden" th:value="${dates}" id="dates" />
                    <a href="javascript:;" class="layui-btn layui-btn-fluid layui-btn-danger" onclick="login()"
                       id="submitBtn">登 录</a>
                </div>

                <div class="certificatType">
                    <p class="unit">1+X证书制度试点 </p>
                    <p class="lv">幼儿照护职业技能等级证书·产后恢复职业技能等级证书 </p>
                </div>

            </div>
        </div>
        <div class="carousel">

            <div class="swiper mySwiper">
                <div class="swiper-wrapper" id="swiper"></div>
            </div>

        </div>
    </div>

</div>

<script>

    function isIE() {
        if (!!window.ActiveXObject || "ActiveXObject" in window)
            return true;
        else
            return false;
    }

    if( isIE() ){
        document.getElementById('tips').style.display = 'block';
    }

</script>

<script src="/js/jquery.min.js?v=2.1.4" th:src="@{/js/jquery.min.js?v='2.1.4'}"></script>
<script src="/js/plugins/layer/layer.min.js" th:src="@{/js/plugins/layer/layer.min.js}"></script>
<script src="/js/swiper-bundle.js"></script>
<script type="text/javascript">


    //回车登录
    var examinationListIntro = null, gather = [] ;
    document.onkeydown =cdk;
    function cdk(){
        if(event.keyCode ==13){
            login();
        }
    }
    var id=null;
    $(function () {

        $.ajax({
            url: "/jzApi/examinations/selExamination",
            async : false,
            success: function (r) {
                //console.log("r",r)
                if(r.code !=-1){
                    if(window.localStorage){
                        //window.localStorage.setItem("intro",JSON.stringify(r.data));
                        // window.localStorage.setItem("backGroundImage",r.data.backGroundImage);
                    }else{
                        layer.msg("请换浏览器，最佳为谷歌")
                    }
                    examinationListIntro = r.data;
                    for(var p in r.data){
                        $("#examinationList").append("<option value='"+r.data[p].id+"'>"+r.data[p].name+"</option>");
                    }
                    $("#title").html('1+X幼儿照护证书在线考试');
                    //id = r.data.id
                }else{
                    $("#title").html('暂无在线考试');
                }
            }
        });

    });

    function login() {
        var username = $("#username").val();
        var idNumber = $("#idNumber").val();
        var ticketNumber = $("#ticketNumber").val();
        var examinationId = $("#examinationList").val();
        if ('' == examinationId) {
            layer.msg('请选择考试批次');
            return false
        }
        if ('' == username) {
            layer.msg('请输入姓名');
            return false
        }
        if ('' == idNumber) {
            layer.msg('请输入考生编号');
            return false
        }
        if ('' == ticketNumber) {
            layer.msg('请输入准考证号');
            return false
        }
        $.ajax({
            type: "POST",
            url:  "/jzApi/examinations/loginExamination",
            data: {id:examinationId,name:username , idNumber:idNumber, ticketNumber:ticketNumber},
            success: function (r) {

                if (r.code == 0) {

                    let userinfo = JSON.parse(window.localStorage.getItem("info"));
                    if( userinfo ){
                        if( r.data.ticketNumber == userinfo.ticketNumber ){
                            location.href = '/examination/startExam'
                        }else{
                            localStorage.clear();
                        }
                    }

                    if(window.localStorage){
                        for(var e in examinationListIntro){
                            if(examinationListIntro[e].id == examinationId){
                                // window.localStorage.setItem("intro"+r.data.idCard,JSON.stringify(examinationListIntro[e]));
                                window.localStorage.setItem("intro",JSON.stringify(examinationListIntro[e]));
                                break;
                            }
                        }
                        window.localStorage.setItem("info",JSON.stringify(r.data));
                        window.localStorage.setItem("nowDate",r.data.nowDate);
                        window.localStorage.setItem("times",JSON.stringify($('#times').val()));
                        window.localStorage.setItem("dates",JSON.stringify($('#dates').val()));
                    }else{
                        layer.msg("请换浏览器，最佳为谷歌")
                    }
                    location.href = '/examination/startExam'
                } else {
                    layer.msg(r.msg);
                }
            }
        });
    }

    $.ajax({
        type: "POST",
        url:  "/jzApi/examinations/serversBanners",
        success: function (r) {
            console.log(r)
            var str = '';
            if (r.code == 0) {
                r.data.forEach(function (item){
                    str += `
                            <div class="swiper-slide slide">
                               <img src="${item.value}" alt="">
                            </div>
                          `;
                })
                $("#swiper").html(str)
            } else {
                layer.msg(r.msg);
            }

            //    轮播图
            var swiper = new Swiper(".mySwiper", {
                autoplay:true
            });

        }
    });


</script>
</body>





